<?php
/*
 * Created on 2014-3-19
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 ini_set('display_errors','0');
 function is_utf8($word)
{
	if (preg_match("/^([".chr(228)."-".chr(233)."]{1}[".chr(128)."-".chr(191)."]{1}[".chr(128)."-".chr(191)."]{1}){1}/",$word) == true || preg_match("/([".chr(228)."-".chr(233)."]{1}[".chr(128)."-".chr(191)."]{1}[".chr(128)."-".chr(191)."]{1}){1}$/",$word) == true || preg_match("/([".chr(228)."-".chr(233)."]{1}[".chr(128)."-".chr(191)."]{1}[".chr(128)."-".chr(191)."]{1}){2,}/",$word) == true)
	{
		return true;
	}
	else
	{
		return false;
	}
}
 function st_get_csv(){
 	$csv=$_FILES['csv'];
 	$re=array();
 	if (empty($csv)) return $re;
 	if (!file_exists($csv['tmp_name']))return $re;
 	
 	$file = fopen($csv['tmp_name'],"r");
 	$num=0;
 	
	while(! feof($file))
	{
		
	  	$arr = (fgetcsv($file));
	  	if ($num==0){
			$num++;
			continue;
		}
		
		if (count($arr)<2) continue;
//		$is_utf8 = @is_utf8($arr[1]);
//		if($is_utf8===TRUE){
//			$arr[1]=@iconv('gbk', 'utf-8', $arr[1]);
//		}
//		$is_utf8 = @is_utf8($arr[1]);
//		if($is_utf8===TRUE){
//			$arr[4]=@iconv('gbk', 'utf-8', $arr[4]);
//		}
	  	$video_name=$arr[1];
	  	$video_status=$arr[2];
	  	$video_type=$arr[3];
	  	$video_indexs=$arr[4];
	  	$video_time=date('Y-m-d H:i:s',strtotime($arr[5]));
	  	$video_id=$arr[7];
	 	//$video_indexs = explode(',',$video_indexs);
	 	
	 	$item=array();
	 	$item['num']=$num;
	 	$item['id']=$video_id;
	 	$item['name']=$video_name;
	 	$item['status']=$video_status;
	 	$item['type']=$video_type;
	 	$item['indexes']=$video_indexs;
		$item['time']=$video_time;
		$re[]=$item;
		$num++;
	}
	
	return $re;
 }
?>
